package com.yangguang.huahui.mvp.model;

import com.yangguang.huahui.api.SupplyApi;
import com.yangguang.huahui.entity.AttentionList;
import com.yangguang.huahui.entity.HttpResult;
import com.yangguang.huahui.entity.Nongzi;
import com.yangguang.huahui.entity.PublishList;
import com.yangguang.huahui.net.NetManager;

import okhttp3.ResponseBody;
import rx.Observable;

/**
 * Created by Administrator on 2017/3/3.
 */

public class SupplyModel {
    public Observable<AttentionList> getSeedlings(int page, String goods_type, String variety){
        SupplyApi supplyApi = NetManager.getInstance().create(SupplyApi.class);
        return supplyApi.getSeedlings(page, goods_type, variety);
    }
    public Observable<AttentionList> getFlowers(int page){
        SupplyApi supplyApi = NetManager.getInstance().create(SupplyApi.class);
        return supplyApi.getFlowers(page);
    }

    /**
     * 找农资
     * @param page
     * @return
     */
    public Observable<Nongzi> getNongzi(int page){
        SupplyApi supplyApi = NetManager.getInstance().create(SupplyApi.class);
        return supplyApi.getNongzi(page);
    }

    /**
     * 找农机
     * @param page
     * @return
     */
    public Observable<Nongzi> getNongji(int page){
        SupplyApi supplyApi = NetManager.getInstance().create(SupplyApi.class);
        return supplyApi.getNongji(page);
    }

    /**
     * 发布
     * @param uid
     * @param goods_type
     * @param variety
     * @param goods_specifications
     * @param goods_title
     * @param source_of_supply_id
     * @param price
     * @param whether_the_spot
     * @param time_to_market
     * @param expire_date
     * @param service_method
     * @param carousel
     * @param contacts
     * @param phone
     * @param supply_mark
     * @param remarks
     * @return
     */
    public Observable<HttpResult> publish(String uid, String goods_type, String variety, String goods_specifications, String goods_title,
                                          String source_of_supply_id, String price, String whether_the_spot, String time_to_market, String expire_date,
                                          String service_method, String carousel, String contacts, String phone, String supply_mark, String remarks){
        SupplyApi supplyApi = NetManager.getInstance().create(SupplyApi.class);
        return supplyApi.publish(uid, goods_type, variety, goods_specifications, goods_title, source_of_supply_id, price, whether_the_spot, time_to_market,
                expire_date, service_method, carousel, contacts, phone, supply_mark, remarks);
    }

    public Observable<PublishList> getPublish(String uid){
        SupplyApi supplyApi = NetManager.getInstance().create(SupplyApi.class);
        return supplyApi.getPublish(uid);
    }

    public Observable<PublishList> delete(String id){
        SupplyApi supplyApi = NetManager.getInstance().create(SupplyApi.class);
        return supplyApi.delete(id);
    }

    public Observable<PublishList> refresh(String id, String uid){
        SupplyApi supplyApi = NetManager.getInstance().create(SupplyApi.class);
        return supplyApi.refresh(id, uid);
    }
}
